#ifndef INSTALL_TSTRING_H
#define INSTALL_TSTRING_H

class TString
{
public:
	enum { MAX_LOCAL_STRING_LEN = 63 };
	
	TString();
	TString(const TCHAR ch);
	TString(const TString& src);
	TString(LPCTSTR lpsz, int nLen = -1);
	virtual ~TString();
	
	static TString RES(UINT nRes);
	
	void Empty();
	int GetLength() const;
	bool IsEmpty() const;
	TCHAR GetAt(int nIndex) const;
	void Append(LPCTSTR pstr);
	void Assign(LPCTSTR pstr, int nLength = -1);
	LPCTSTR GetData();
	
	void SetAt(int nIndex, TCHAR ch);
	operator LPCTSTR() const;
	
	TCHAR operator[] (int nIndex) const;
	const TString& operator=(const TString& src);
	const TString& operator=(const TCHAR ch);
	const TString& operator=(LPCTSTR pstr);
#ifndef _UNICODE
	const TString& TString::operator=(LPCWSTR lpwStr);
#endif
	TString operator+(const TString& src);
	TString operator+(LPCTSTR pstr);

	const TString& operator+=(const TString& src);
	const TString& operator+=(LPCTSTR pstr);
	const TString& operator+=(const TCHAR ch);
	
	bool operator == (LPCTSTR str) const;
	bool operator != (LPCTSTR str) const;
	bool operator <= (LPCTSTR str) const;
	bool operator <  (LPCTSTR str) const;
	bool operator >= (LPCTSTR str) const;
	bool operator >  (LPCTSTR str) const;
	
	int Compare(LPCTSTR pstr) const;
	int CompareNoCase(LPCTSTR pstr) const;
	
	void MakeUpper();
	void MakeLower();
	
	TString Left(int nLength) const;
	TString Mid(int iPos, int nLength = -1) const;
	TString Right(int nLength) const;
	
	int Find(TCHAR ch, int iPos = 0) const;
	int Find(LPCTSTR pstr, int iPos = 0) const;
	int ReverseFind(TCHAR ch) const;
	int Replace(LPCTSTR pstrFrom, LPCTSTR pstrTo);
	
	int __cdecl Format(LPCTSTR pstrFormat, ...);
	
protected:
	LPTSTR m_pstr;
	TCHAR m_szBuffer[MAX_LOCAL_STRING_LEN + 1];
};

#endif